

**************LT Max 31-36 then sum 1-30 days
use "$path\Intermediary Data\base_estim_EG_0821_sp95.dta", clear

egen idb=group(id)

egen lt_effect=rowmax(coeff1_reg_31-coeff1_reg_36)
winsor2 lt_effect , replace  cuts(1 99) trim
foreach i of numlist 0/40{

gen y_`i'=coeff1_reg_`i'/lt_effect
}

qui  egen CIR_2=rowtotal( y_1-y_30)
qui  egen sc=rowtotal( coeff2_reg_1-coeff2_reg_30)
qui  egen sc10=rowtotal( coeff2_reg_1-coeff2_reg_10)

foreach i of numlist 2/30{

qui  egen CIR_h`i'=rowtotal( y_1-y_`i')

}

keep id CIR_h* CIR_2 lt_effect sc*
drop if CIR_2==0
save "$path\Intermediary Data\base_CIR2_sp95", replace

